package java8stream;

import java.util.Optional;

/**
 * Created by ZhuQianli on 2018/1/16.
 */
public class OptionalNullValue {
    public static void main(String[] args) {

        println(null);
        println("asd");

    }

    public static void println(String text) {
        Optional.ofNullable(text).ifPresent(System.out::println);
    }

    public static int getLength(String text) {
        return Optional.ofNullable(text).map(String::length).orElse(-1);
    }
}
